package common;

import java.util.concurrent.TimeUnit;

public class Ask extends Auction {
	private static final long serialVersionUID = -3697370311263529902L;
	
	public Ask( String owner, Commodity commodity, double price, int quantity, long duration, TimeUnit time) {
		super(owner, commodity, price, quantity, duration, time);
	}

	@Override
	public boolean isValid(double price, int quantity) {
		return !invalidCommodity() && !invalidAskPrice( price ) && !overQuantity( quantity ) && this.quantity > 0;
	}
	public boolean isValid(CommodityLimits L) {
		return (!L.isBuyer && isValid(L.bound, L.quota));
	}
	public boolean isValidMatch(Auction a) {
		return (a.quantity == super.quantity && price <= a.price); 
	}
	
	public boolean invalidAskPrice( double price ) {
		return super.price < price;
	}
	
	public String getType() {
		return "Ask";
	}
	public String toString() {
		return "Ask  \t"+super.toString();
	}
	

}
